{% from "macros.jinja" import hiding_control, format_output %}
{% extends "base_logged.html" %}

{% block page %}
<div id="page-wrapper">

<div class="row">
  <div class="col-lg-12">
    <h1>{{ job.info.Function }} on {{ job.info.Target }} started at {{ job.info.StartTime }} by {{ job.info.User }} <small>Arguments {{ job.info.Arguments|format_arguments }}  <a href="{{ url_for('redo_job', jid=job.info.jid, minion=minion, renderer=renderer) }}"><button class="btn btn-primary btn-sm"><i class="fa fa-refresh"></i> Redo job with same parameters</button></a></small> </h1>
    {% if job.info.Function == 'state.highstate' and renderer != 'highstate' %}
    <div class="alert alert-warning"><a href="{{ url_for('job_result', jid=job.info.jid, renderer='highstate', minion=minion) }}">It looks like a state.highstate output, click here to see this page with the highstate renderer</a></div>
    {% elif job.info.Function != 'state.highstate' and renderer == 'highstate' %}
    <div class="alert alert-warning"><a href="{{ url_for('job_result', jid=job.info.jid, renderer='raw', minion=minion) }}">It doesn't looks like a state.highstate output, click here to see this page with the raw renderer</a></div>
    {% endif %}

    <!-- Aggregate -->
    {% if job.info.Function != 'state.highstate' and renderer != 'aggregate' %}
    <div class="alert alert-info"><a href="{{ url_for('job_result', jid=job.info.jid, renderer='aggregate', minion=minion) }}">Aggregate results</a></div>
    {% elif job.info.Function != 'state.highstate' and renderer == 'aggregate' %}
    <div class="alert alert-info"><a href="{{ url_for('job_result', jid=job.info.jid, renderer='raw', minion=minion) }}">Raw results</a></div>
    {% endif %}
    <ol class="breadcrumb">
      <li><a href="{{ url_for('index') }}"><i class="fa fa-dashboard"></i> SaltPad</a></li>
      <li><a href="{{ url_for('jobs') }}"><i class="fa fa-tasks"></i> Jobs</a></li>
      <li class="active"><i class="fa fa-cloud"></i> Job {{ job.info.jid }}</li>
    </ol>
  </div>
</div><!-- /.row -->

{% if job.status == 'running' %}

  <div class="row">
    <div class="col-lg-12">
      <div class="alert alert-info">
        <h1><i class="fa fa-refresh fa-spin"></i> Job is running, please wait !</h1>
        <script type="text/JavaScript">
        setTimeout(function(){
          window.location.reload(1);
        }, 5000);
        </script>
      </div>
    </div>
  </div>

{% else %}

  {% block job_result %}
  {% endblock %}

{% endif %}

{% endblock %}
